<?php

    $user = @$data['User'];
    unset($user['password']);

?><?= $this->Form->create('User', array('url'=>'/users/save', 'class'=>'left')) ?>
    <?= $this->Html->link('&laquo; nazad', '/users', array('escape'=>false)) ?>
    
    <?= $this->Form->hidden('id', array('value' => @$user['id'])) ?>
    
    <?= $this->Form->submit('Sačuvaj', array('div'=>false, 'class'=>'right')) ?>
    <? if ((int)$user['id']>0): ?>
    <?= $this->Form->submit('Obriši', array(
        'div'     => false, 
        'type'    => 'button',
        'class'   => 'right delete',
        'onclick' => 'if(confirm(\'Da li želite da obrišete korisnika?\')){location.href=\'/users/delete/'.$user['id'].'\'}'
    )) ?>
    <? endif ?>
    
    <?= $this->Form->label('role', 'Tip naloga:') ?>
    <?= $this->Form->select('role', $roles, array('value'=>@$user['role'], 'empty'=>false)) ?>
    
    <?= $this->Form->label('name', 'Ime i prezime:') ?>
    <?= $this->Form->text('name', array('value'=>@$user['name'], 'class'=>'large')) ?>
    
    <?= $this->Form->label('username', 'Korisničko ime:') ?>
    <?= $this->Form->text('username', array('value'=>@$user['username'])) ?>
    <span class="error-container"><?= $this->Form->error('username') ?></span>
    <span class="input-info info left">*minimum 4 karaktera</span>
    
    <?= $this->Form->label('password', 'Lozinka:') ?>
    <?= $this->Form->password('password') ?>
    <?= $this->Form->password('password2') ?>

<?= $this->Form->end() ?>